<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        用户名<input :value="username" id="username"/>

        <button @click="setusername">点击设置值</button>

    </div>
</body>
<script>
    new  Vue({
        el:"#app",
        data:{
            username:"leson"
        },
        methods:{
            setusername(){
                let usernameInput = document.getElementById("username");
                this.username = "lala";//数据更新
                // setTimeout(()=>{
                //     console.log(usernameInput.value);//到页面更新 消耗了时间
                // },0)
                this.$nextTick(()=>{
                    console.log(usernameInput.value);//到页面更新 消耗了时间
                })
      

            }
        }
    })

</script>
</html>